<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<div th:include="common/yljg-modal :: yljg-modal" />
<div th:include="common/common-export :: common-export" />
<title>医联体</title>
<style type="text/css">
</style>
</head>
<script th:inline="javascript">
	/**用户信息*/
	var userInfo = [[${userInfo}]];
</script>
<script type="text/javascript">
$(function() {
	$(this).registerManagerPage();
	enterToQuery(queryForm);
 	initView();
});

function queryForm() {
	$("#qysqForm").datagrid("reload");
	/**禁用更新按钮*/
	if($("#btnUpdate").attr("disabled")!="disabled"){
		$("#btnUpdate").attr("disabled", "disabled");
	}
	/**清空勾选*/
	selectionIds = [];
}

function initView()
{
	var opt ={
			idField : "YLJGID",
			uniqueId: "YLTID",
			striped : true,
			border:false,
			toolbar : "#dgFormToolbar",
			columns : [[
				/* {
					field: "checkStatus",
					checkbox: true
				}, */
				{
					field : "YLTMC",
					width: 250,
					align: "center",
					title : "医联体名称"
				},
				{
					field : "ZDYLJGMC",
					width: 250,
					align: "center",
					title : "主导机构"
				},
				{
					field : "YLTLXMC",
					width: 150,
					align: "center",
					title : "医联体类型"
				},
				{
					field : "CJSJ",
					width: 150,
					align: "center",
					title : "创建时间",
					formatter : function(value, row, index){
						if(!StringUtils.isEmpty(value)){
							value = value.substr(0, 10);
						}
						return value;
					}
				},
				{
					field : "QYYXQMC",
					width: 150,
					align: "center",
					title : "签约有效期",
				},
				{
					field : "cz",
					width: 100,
					align: "center",
					title : "操作",
					formatter : operateFormatter
				}
			]]
			,pagination : true
			,pageNumber: 1
			,pageSize: 10
			,fit: true
			,fitColumns: true
			,singleSelect: false
			,rownumbers: true
			,method : "post"
			,url: contextRoot+"jrylt/queryPage.service"
			,onBeforeLoad:function(params){
				params["YLTMC"] = $("#YLTMC").val();
				params["YLTLX"] = $("#YLTLX").val();
				params["ZDYLJGMC"] = $("#ZDYLJGMC").val();
				params["ZDYLJGID"] = userInfo["PTJGID"];
				params["JGLX"] = "2";
				return params; 
			}
		};
	$("#qysqForm").datagrid(opt);
	
	/**禁用修改按钮*/
	$("#btnUpdate").attr("disabled", "disabled");
	
	/**加载选择方法*/
	SelectCheckBox("YLTID","qysqForm", "btnUpdate", opt);
	
	/**查询医联体*/
	$("#btnQuery").on("click", function(){
		queryForm();
	});
	
	/**加入医联体*/
	$("#btnJoin").on("click", function(){
		$.QuickUrlUtils.redirectUrl("manager.html?YLJGID="+userInfo["PTJGID"]);
	});
	
	/**导出医联体*/
	$("#btnExport").on("click", function(){
		$("#ZDYLJGID").val(userInfo.PTJGID);
		$("#exportForm").submit();
	});
	
	$("#xzYljg").on("click", function(){
		//页面层
		parent.layer.open({
		  type: 1,
		  area: ["80%", "500px"], //宽高
		  scrollbar: false,
		  resize: false,
		  content: $("#yljgModal").html(),
		  move: false,
		  btn: ["确定", "取消"],
		  success: function(layero, index){
			  initYljgTable(layero);
		  },
		  yes: function (index, layero) {
          			var info = $(layero).find("#yljgForm").datagrid("getSelected")
         			$("#YLJGMC").val(info["YLJGMC"]);
			  		$("#YLJGID").val(info["PTJGID"]);
			  		parent.layer.close(index);//这块是点击确定关闭这个弹出层
          }
		});
	});
	
}

/**操作格式化*/
function operateFormatter(value, row, index) {
	var tool = $("#tableToolBar").html();
	return tool.replace(/#index#/g,index);;
}

/**详细按钮*/
function detail(index){
	/**清除所有选择*/
	$("#qysqForm").datagrid("clearSelections");
	/**选中当前行*/
	$("#qysqForm").datagrid("selectRow", index);
	/**获取选中行数据*/
	var row = $("#qysqForm").datagrid("getSelected", index);
	$.QuickUrlUtils.redirectUrl("detail.html?YLTID="+row["YLTID"]+"&YLJGID="+userInfo["PTJGID"]);
}

/**获取状态*/
function getZt(zt){
	if(zt == "01"){
		zt = "暂存";
	}
	else if(zt == "02"){
		zt = "待接收";
	}
	else if(zt == "03"){
		zt = "已签约";
	}
	else if(zt == "04"){
		zt = "拒绝";
	}
	else if(zt == "05"){
		zt = "已到期";
	}
	return zt;
}

/**校验是否选中医联体*/
function validate(info){
	if(StringUtils.isEmpty(info)){
		return false;
	}else{
		return true;
	}
}
</script>

<body class="easyui-layout" fit="true">

<div region="north" style="border: none; overflow: hidden;">
		<h4 class="h4-title" style="text-align:center;margin:0;padding:0;font-size: 18px;">
			加入医联体
		</h4>
	</div>
	<div region="center" style="border: none;">
		
		<div id="dgFormToolbar" style="background: white;">
			<form id="exportForm" action="export.service" enctype="multipart/form-data">
				<table class="form-table" style="margin:0;padding:0;">
					<tr>
						<td class="td-text">医联体名称：</td>
						<td class="td-content">
							<input type="hidden" name="ZDYLJGID" id="ZDYLJGID" />
							<input type="hidden" name="JGLX" value="2" />
						
							<input id="YLTMC" name="YLTMC" class="form-control dataField"/>
						</td>
						<td class="td-text">医联体类型：</td>
						<td class="td-content">
							<select id="YLTLX" name="YLTLX" class="form-control " cacheTable="TB_ZY_YLTLX">
							</select>
						</td>
						</td>
						<td class="td-text">主导机构名称：</td>
						<td class="td-content">
							<input id="ZDYLJGMC" name="ZDYLJGMC" class="form-control dataField"/>
						</td>
						<td class="td-text" style="text-align:center;width:160px;">
							<button id="btnQuery" class="btn btn-info" type="button">查询</button>
						</td>
					</tr>
				</table>
			</form>
			<div style="margin:10px 10px auto 0px;">
				<button id="btnExport" class="btn btn-info" type="button">导出</button>
				<button id="btnJoin" class="btn btn-info" type="button">加入医联体</button>
			</div>
		</div>
		<div class="easyui-layout" style="border: none;">
			<div region="center" style="border: none;">
				<table id="qysqForm">
				</table>
			</div>
		</div>
	</div>
</body>
<script type="text/html" id="tableToolBar">
<a class="tableToolBarBtn" href="javascript:detail(#index#)" title="详细" >详细</a>
</script>
</html>



